import dva from 'dva';
import './index.css';
import { message } from 'antd';
import createLogger from 'redux-logger';
// import createLoading from 'dva-loading'
let log;
if (process.env.NODE_ENV === `development`) {
  log = createLogger;
} else {
  log = () => {};
}
// 1. Initialize
const app = dva({
  initialState: {
    products: [
      {name: 'dva', id: 1},
      {name: 'antd', id: 2},
    ]
  },
  onError(e) {
    message.error(e.message, 3)
  },
  onAction: log//在action被dispatch时触发，用于注册 redux 中间件。支持函数或函数数组格式
  // onError,
  // onAction,
  // onStateChange,
  // onReducer,
  // onEffect,
  // onHmr,
  // extraReducers,
  // extraEnhancers,
});

// 2. Plugins
// app.use({});

// 3. Model
app.model(require('./models/products').default);
app.model(require('./models/loginModel').default);

// 4. Router
app.router(require('./router').default);

// 5. Start
app.start('#root');
